<form [formGroup]="contactForm" (submit)="onSubmit()">
  <div formArrayName="contacts">
    <!--contacts是FormArray，其controls是一个FormGroup数组，其索引就是formGroupName-->
    <div
      *ngFor="let contact of contacts.controls; let i = index"
      [formGroupName]="i"
    >
      <input type="text" formControlName="name" />
      <input type="text" formControlName="address" />
      <input type="text" formControlName="phone" />
      <button (click)="removeContact(i)">删除联系方式</button>
    </div>
  </div>
  <button (click)="addContact()">添加联系方式</button>
  <button>提交</button>
</form>
